local sk__quanxiang = fk.CreateSkill {

  name = "sk__quanxiang",

  tags = {  },

}



sk__quanxiang:addEffect("active", {
  name = "sk__quanxiang",
  anim_type = "offensive",
  card_num = 0,
  target_num = 1,
  prompt = "#sk__quanxiang",
  can_use = function(self, player)
    return not player:isKongcheng() and player:getMark("@@sk__quanxiang-phase") == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter =function (self, player, to_select, selected, selected_cards)
        return #selected == 0 and to_select ~= player and player:canPindian(to_select)
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    local target = effect.tos[1]
    local pindian = player:pindian({target}, sk__quanxiang.name)
    if pindian.results[target].winner == player then
      local n = target.hp
      if not player.dead then
        room:setPlayerMark(player, "@@sk__quanxiang-phase", 1)
      end
      if not target.dead then
        room:loseHp(target, n, sk__quanxiang.name)
      end
      if not target.dead and target:isWounded() then
        room:recover({
          who = target,
          num = math.min(n, target:getLostHp()),
          recoverBy = player,
          skillName = sk__quanxiang.name,
        })
      end
      if not player.dead then
        room:addPlayerMark(player, "@sk__wanglang_raoshe", 1)
      end
    else
      if not player.dead then
        room:addPlayerMark(player, "@sk__wanglang_raoshe", 2)
      end
    end
    if not player.dead and player:getMark("@sk__wanglang_raoshe") > 6 then
      room:killPlayer({who = player,})
    end
  end,
})

return sk__quanxiang